var app = getApp();
var util = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name: '',
    phone: '',
    address: '',
    productName: '',
    productImg: '',
    productMoney: "",
    productNumber: "",
    orderMoney: "",
    giveExpenses: "",
    total: "",
    time: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    wx.getStorage({
      key: 'openid',
      success: function(res) {
        let openid = res.data

        wx.request({
          url: app.globalData.URL + '/app/personalOrder/orderDetailed?id=' + options.id + '&type=' + options.type + '&openid=' + openid,
          success: function (res) {
            console.log(res.data)

            var total = Number(res.data.order.orderMoney) + Number(res.data.order.giveExpenses)

            var time = util.formatTime(res.data.order.createDate);

            that.setData({
              name: res.data.order.name,
              phone: res.data.order.tel,
              address: res.data.order.address + res.data.order.details,
              productName: res.data.list[0].productName,
              productMoney: res.data.list[0].productMoney,
              productNumber: res.data.list[0].productNumber,
              orderMoney: res.data.order.orderMoney,
              giveExpenses: res.data.order.giveExpenses,
              total: total,
              time: time,
            })
          }
        })
      },
    })
    
  },

  
})